<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>dome2</title>
    <script src="../index.js"></script>
</head>
<body>

<button onclick="setUserData()">设置用户信息</button>
<button onclick="openSystem()">启动</button>
<button onclick="closeSystem()">关闭</button>

<script>

    var {AntiShakeAndPer, AntiShakeAndPerConfig} = AntiShakeAndPer

    var antiShakeAndPer = new AntiShakeAndPer(new AntiShakeAndPerConfig(
        function () {
            console.log('请求中')
        },
        function () {
            console.log('结束')
        },
        function (type) {
            if (type === 1) {
                console.log('请勿重复请求')
            }
            if (type === 2) {
                console.log('没有权限')
            }
        },
        10000
    ), ['OPEN_SYSTEM', 'CLOSE_SYSYTEM'])

    var setUserData = function () {
        antiShakeAndPer.run(function (done) {
            console.log('SET_USER_DATA')
            setTimeout(function () {
                done()
            }, 3000)
        }, 'SET_USER_DATA')
    }

    var openSystem = function () {
        antiShakeAndPer.run(function (done) {
            console.log('OPEN_SYSTEM')
            setTimeout(function () {
                done()
            }, 3000)
        }, 'OPEN_SYSTEM')
    }

    var closeSystem = function () {
        antiShakeAndPer.run(function (done) {
            console.log('CLOSE_SYSYTEM')
            setTimeout(function () {
                done()
            }, 3000)
        })
    }
</script>
</body>
</html>
